/*
 * ReturnExpressionAst.cpp
 *
 *  Created on: 8 Nov 2010
 *      Author: kn308
 */

#include <MAlice/Ast/ReturnExpressionAst.h>
#include <MAlice/Codegen.h>
#include <MAlice/Parser/location.hh>

namespace MAlice
{

ReturnExpressionAst::ReturnExpressionAst(location loc, ExpressionAst* expression) : ExpressionAst(loc),
	mExpression(expression)
{
	MALICE_TRACE;
}

ReturnExpressionAst::~ReturnExpressionAst()
{
	MALICE_TRACE;
}

llvm::Value* ReturnExpressionAst::generate()
{
	MALICE_TRACE;
	return Codegen::get()
			->getBuilder()
			->CreateRet(getExpression()->generate());
}

}
